package com.sky.controller.admin;

import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.*;

@RestController("adminShopController")
@RequestMapping("/admin/shop")
@Api( tags = "店铺操作接口")
public class ShopController {
    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @PutMapping("{status}")
    @ApiOperation("设置营业状态")
    public Result setStatus(@PathVariable Integer status){
        stringRedisTemplate.opsForValue().set("SHOP_STATUS", status.toString());
        return Result.success();
    }

    @GetMapping
    @ApiOperation("设置营业状态")
    public Result<Integer> selectStatus(){
        String status = stringRedisTemplate.opsForValue().get("SHOP_STATUS");
        int s = Integer.parseInt(status);
        return Result.success(s);
    }
}
